Fix for PR18735 - self-assignment for map/multimap gives incorrect results in C++03 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@201021 91177308-0d34-0410-b5e6-96231b3b80d8 
diff --git a/include/map b/include/map index 009e8e2..9779b70 100644 --- a/include/map +++ b/include/map 
@@ -884,10 +884,12 @@  #if __cplusplus >= 201103L  __tree_ = __m.__tree_;  #else - __tree_.clear(); - __tree_.value_comp() = __m.__tree_.value_comp(); - __tree_.__copy_assign_alloc(__m.__tree_); - insert(__m.begin(), __m.end()); + if (this != &__m) { + __tree_.clear(); + __tree_.value_comp() = __m.__tree_.value_comp(); + __tree_.__copy_assign_alloc(__m.__tree_); + insert(__m.begin(), __m.end()); + }  #endif  return *this;  } @@ -1616,10 +1618,12 @@  #if __cplusplus >= 201103L  __tree_ = __m.__tree_;  #else - __tree_.clear(); - __tree_.value_comp() = __m.__tree_.value_comp(); - __tree_.__copy_assign_alloc(__m.__tree_); - insert(__m.begin(), __m.end()); + if (this != &__m) { + __tree_.clear(); + __tree_.value_comp() = __m.__tree_.value_comp(); + __tree_.__copy_assign_alloc(__m.__tree_); + insert(__m.begin(), __m.end()); + }  #endif  return *this;  } 
diff --git a/include/unordered_map b/include/unordered_map index 78fee48..4e2298b 100644 --- a/include/unordered_map +++ b/include/unordered_map 
@@ -831,12 +831,14 @@  #if __cplusplus >= 201103L  __table_ = __u.__table_;  #else - __table_.clear(); - __table_.hash_function() = __u.__table_.hash_function(); - __table_.key_eq() = __u.__table_.key_eq(); - __table_.max_load_factor() = __u.__table_.max_load_factor(); - __table_.__copy_assign_alloc(__u.__table_); - insert(__u.begin(), __u.end()); + if (this != &__u) { + __table_.clear(); + __table_.hash_function() = __u.__table_.hash_function(); + __table_.key_eq() = __u.__table_.key_eq(); + __table_.max_load_factor() = __u.__table_.max_load_factor(); + __table_.__copy_assign_alloc(__u.__table_); + insert(__u.begin(), __u.end()); + }  #endif  return *this;  } @@ -1567,12 +1569,14 @@  #if __cplusplus >= 201103L  __table_ = __u.__table_;  #else - __table_.clear(); - __table_.hash_function() = __u.__table_.hash_function(); - __table_.key_eq() = __u.__table_.key_eq(); - __table_.max_load_factor() = __u.__table_.max_load_factor(); - __table_.__copy_assign_alloc(__u.__table_); - insert(__u.begin(), __u.end()); + if (this != &__u) { + __table_.clear(); + __table_.hash_function() = __u.__table_.hash_function(); + __table_.key_eq() = __u.__table_.key_eq(); + __table_.max_load_factor() = __u.__table_.max_load_factor(); + __table_.__copy_assign_alloc(__u.__table_); + insert(__u.begin(), __u.end()); + }  #endif  return *this;  }